package dk.nineconsult.jmoller;

import org.eclipse.xtext.common.types.JvmFeature;
import org.eclipse.xtext.common.types.JvmField;
import org.eclipse.xtext.common.types.JvmOperation;
import org.eclipse.xtext.common.types.JvmTypeReference;

public class TypeUtils {

	final static public JvmTypeReference typeOf(JvmFeature feature) {
		if (feature instanceof JvmOperation) {
			if (feature.getSimpleName().startsWith("set"))
				return ((JvmOperation)feature).getParameters().get(0).getParameterType();
			else
				return ((JvmOperation)feature).getReturnType();
		} else if (feature instanceof JvmField) {
			return ((JvmField)feature).getType();
		} else return null;
	}
}